import React, { useState } from 'react';

export default function Testtwo() {
  let [num, setNum] = useState(0);
  const handle = () => {
    setNum(100);
    setTimeout(() => {
      console.log(num); //打印的值为什么是0? 根据作用域链往上找,找到num=0
    }, 2000);
  };
  return (
    <>
      <span>{num}</span>
      <button onClick={handle}>新增</button>
    </>
  );
}
